<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- <meta http-equiv="X-UA-Compatible" name="renderer" content="text/html; charset=utf-8;IE=EmulateIE8" /> -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<title>无纸化病案管理系统-登录</title>
<link rel="shortcut icon" href="<%=path%>/image/LOGO.png" type="image/x-icon">
<link rel="stylesheet" href="<%=path%>/css/login.css">
<script type="text/javascript" src="<%=path%>/script/jquery-easyui-1.4.5/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/script/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=path%>/script/jquery-easyui-1.4.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-easyui-1.4.5/jquery.easyui.extend.js"></script>
<link rel="stylesheet" type="text/css" href="<%=path%>/script/jquery-easyui-1.4.5/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/script/jquery-easyui-1.4.5/themes/icon.css" />

</head>
<body>
 <div id="content" >
        <div class="contentTop" style="border:0px solid red;">
            <table  class="table" style="border:0px solid #e3e2e3;">
                <tr>
                  <td style="padding-left:20px;border-bottom:1px solid #e3e2e3;">
                      <div style="height:64px;line-height:64px;">
                   	 	 <img src="<%=path%>/image/login_logo.png">
                   	  </div>
                  </td>
                  <td style="height:90px;width:231px;">
				   	 <div class="contentTop_Right">
				   	    <span class="titleFont">无纸化病案管理系统</span>
				   	 </div>
				  </td> 
                </tr>
            </table>
        </div>

        <div class="contentMiddle" style="border: 0px solid blue;">
            <span class="titleFont"></span>
        </div>

        <div class="contentBottom" style="border: 0px solid red;">
           <table class="table">
               <tr>
                   <td>
                        <!-- 对客户的资料进行保密，不需浏览器弹出记住密码, autocomplete="off" 来关闭记录   -->
                        <input id="username" class="easyui-textbox" data-options="events:{focus:checkLoginName},iconCls:'icon-man',iconAlign:'left',prompt:'请输入用户名',width:360,height:30"/>  
                   </td> 
               </tr> 
               
               <tr>
                   <td style="padding-top: 32px;"> 
                      <span id="passwordTSpan">
                 	     <input id="passwordT" class="easyui-textbox" data-options="events:{focus:pwdTfocus,keydown:pwdTkeydown},iconCls:'icon-lock',iconAlign:'left',prompt:'请输入密码',width:360,height:30"/>
                      </span>
                      <span id="passwordSpan" style="display:none">
                         <input id="password" type="password"  class="easyui-textbox" data-options="events:{focus:pwdfocus,blur:pwdblur},iconCls:'icon-lock',iconAlign:'left',width:360,height:30"/>
                      </span>
                      <!--  <input id="pwd" type="text"  value="请输入密码" style="color:#ccc"
	                 	    onfocus="if(this.value==defaultValue) {this.value='';this.type='password'}" onblur="if(!value) {value=defaultValue; this.type='text';}" /> -->
                   </td>                  
               </tr>
				 
			    <tr>
                   <td> 
                       <div class="subMsgBack" id="subMsgBack">
	                        <div id="upMsg" class="subMsg"><!-- 请输入正确的用户名/密码 --></div>
	                        <div id="dataMsg" class="subMsg"><!-- 用户名或密码不正确 --></div> 
                      </div>
                   </td> 
               </tr>
               <tr>
                   <td style="padding-top: 64px;">
                       <a href="javascript:submit();" id="submit" class="login_link">登&nbsp;&nbsp;录</a>
                   </td>
               </tr>
           </table>
        </div>
 </div>

  <div class="footer" style="display:none">
      <div class="footer_summary">安全<span class="spacing">&nbsp;</span>快捷<span class="spacing">&nbsp;</span>高效</div>
      <div class="footer_split_line"><span><img src="<%=path%>/image/white_line.png"/></span></div>
  </div>
 
  
<%-- <script type="text/javascript" src="<%=path%>/script/jquery-easyui-1.4.5/jquery.min.js"></script> --%>
<script type="text/javascript">
	 

	/** 
	  * 在页面中任何嵌套层次的窗口中获取顶层窗口 
	  * @return 当前页面的顶层窗口对象 
	  */
	if(window.document.URL.indexOf("manageLogin")==-1){
	  //location.href="manageLogin";
	}
	document.onkeydown=function(event){
		e = event ? event : (window.event ? window.event : null);
		if(e.keyCode==13){
			submit();  //调用登录按钮的登录事件
	    }
	} 
	
	function checkLoginName(){
		  document.getElementById("subMsgBack").style.display ="none";
	}   
	
	function pwdTfocus(){
		 document.getElementById("subMsgBack").style.display ="none";
	} 
	function pwdTkeydown(){
		document.getElementById("subMsgBack").style.display ="none"; 
	    document.getElementById("passwordTSpan").style.display ="none";
	    document.getElementById("passwordSpan").style.display ="block";
	    $('#password').next('span').find('input').focus(); 
	} 
	
	function pwdfocus(){
		 document.getElementById("subMsgBack").style.display ="none";
	} 
	function pwdblur(){
		 document.getElementById("subMsgBack").style.display ="none";  
		 if(this.value==""){
			  document.getElementById("passwordTSpan").style.display ="block";
			  document.getElementById("passwordSpan").style.display ="none"; 
		 } 
	} 

	 //方法二：IE8不通过
	/* $(function(){  
  		//document.getElementById("passwordSpan").style.display ="none";
  		//document.getElementById("password").style.display ="none";
  		//$("#password").next().hide(); 
  		//$("#password").next().css('display','none'); 
  		//$('#password').next(".textbox").hide(); 
  		
  		 $("input",$("#passwordT").next("span")).focus( function(){  
			   document.getElementById("subMsgBack").style.display ="none"; 
		 });
		 $("input",$("#passwordT").next("span")).keydown( function(){  
			   document.getElementById("subMsgBack").style.display ="none";
			   
			   document.getElementById("passwordTSpan").style.display ="none";
			   document.getElementById("passwordSpan").style.display ="block";
			   $('#password').next('span').find('input').focus();  
		  }); 
		 
		 $("input",$("#password").next("span")).focus( function(){ 
			   document.getElementById("subMsgBack").style.display ="none"; 
		 });
		 $("input",$("#password").next("span")).blur( function(){ 
			   document.getElementById("subMsgBack").style.display ="none";
			   
			   if(this.value==""){
				   document.getElementById("passwordTSpan").style.display ="block";
				   document.getElementById("passwordSpan").style.display ="none";
			      //$("#passwordT").next().show();
			      //$("#password").next().hide();
			   }        
		  });
		 
		 //方法三：IE8不通过
		   $("input",$("#password").next("span")).focus( function(){ 
			   document.getElementById("subMsgBack").style.display ="none";
			     $("#passwordT").next().show();
			     $("#password").next().show();
			     if(this.placeholder) { 
				   $("#password2").next().hide();
			     }    
		  });
		 
		 $("input",$("#password").next("span")).blur( function(){  
			   if(this.value=="请输入密码"){
				   this.value=this.defaultValue; this.type='text';
			   }  
		 }); 
	});*/
  	
	function submit() { 
		var username = $("#username").val();
		var password = $("#password").val();
		var focusid = document.activeElement.id;
		if (username == null || username == "") {
			document.getElementById("subMsgBack").style.display ="block"; 
		 
			$("#upMsg").text("用户名不能为空！");
			return;
		}
		if (password == null || password == "") {
			$("#subMsgBack").css('display','block');
			
			$("#upMsg").text("密码不能为空！");
			$("#password").type="text"
			return;
		}
		
	    if(false==regUserName(username)){ 
	       $("#subMsgBack").css('display','block');
		   $("#upMsg").text("用户名不能输入特殊字符！");
			return; 
 		}  
		
		$.ajax({
			url : "<%=path%>/logon",
			type : "post",
			data : {
				username : username,
				password : password
			},
			success : function(data) {
				if (data.success == true) {
					window.location.href = "<%=path%>" + data.url;
				} if(data.success == false) {
					$("#subMsgBack").css('display','block');
					$("#upMsg").text(data.msg);
				}
			}
		});
	};
	
    //正表达式-数字,字母和汉字验证 
	 function regUserName(str){ 
	 	//判断文本框不能输入特殊字符的正则表达式  能输入英文大小写字母、数字、中文 但不能输入特殊字符 
	 	var reg = /^([\u4e00-\u9fa5]+|[a-zA-Z0-9]+)$/; 
	 	if(str.match(reg) ==null){
	 		return false;
	 	}else{
	 		return true;
	 	}
	 }
</script>
</body>
</html>
